package com.aifast.system.sys.dao;

import cn.hutool.core.util.StrUtil;
import com.aifast.system.sys.entity.SysRole;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.Objects;

/**
 * <p>
 * 角色表 Mapper 接口
 * </p>
 *
 * @author fujian
 * @since 2021-12-30
 */
@Mapper
public interface SysRoleDao extends BaseMapper<SysRole> {

    default LambdaQueryWrapper<SysRole> list(String search, Integer permissionType){
        return new LambdaQueryWrapper<SysRole>()
                .eq(!Objects.equals(null,permissionType), SysRole::getPermissionType, permissionType)
                .and(StrUtil.isNotBlank(search), i-> i.like(SysRole::getName,search).or().like(SysRole::getCode,search).or().like(SysRole::getRemarks,search))
                .orderByAsc(SysRole::getId);
    }

}
